home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbpntwin.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  6.6 KB  |  270 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.58.19;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* $XConsortium: mfbpntwin.c,v 5.6 89/11/24 18:03:47 rws Exp $ */
  27. /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  28. /***********************************************************
  29. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  30. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  31.  
  32.                         All Rights Reserved
  33.  
  34. Permission to use, copy, modify, and distribute this software and its 
  35. documentation for any purpose and without fee is hereby granted, 
  36. provided that the above copyright notice appear in all copies and that
  37. both that copyright notice and this permission notice appear in 
  38. supporting documentation, and that the names of Digital or MIT not be
  39. used in advertising or publicity pertaining to distribution of the
  40. software without specific, written prior permission.  
  41.  
  42. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  43. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  44. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  45. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  46. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  47. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  48. SOFTWARE.
  49.  
  50. ******************************************************************/
  51.  
  52. #include "X.h"
  53.  
  54. #include "windowstr.h"
  55. #include "regionstr.h"
  56. #include "pixmapstr.h"
  57. #include "scrnintstr.h"
  58.  
  59. #include "mfb.h"
  60. #include "maskbits.h"
  61.  
  62. extern void miPaintWindow();
  63.  
  64. /*
  65. NOTE
  66.    PaintArea32() doesn't need to rotate the tile, since
  67. mfbPositionWIndow() and mfbChangeWindowAttributes() do it.
  68. */
  69.  
  70. static void mfbPaintWindow32();
  71.  
  72. void
  73. mfbPaintWindow(pWin, pRegion, what)
  74.     WindowPtr    pWin;
  75.     RegionPtr    pRegion;
  76.     int        what;
  77. {
  78.     register mfbPrivWin    *pPrivWin;
  79.  
  80.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  81.     
  82.     switch (what) {
  83.     case PW_BACKGROUND:
  84.     switch (pWin->backgroundState) {
  85.     case None:
  86.         return;
  87.     case ParentRelative:
  88.         do {
  89.         pWin = pWin->parent;
  90.         } while (pWin->backgroundState == ParentRelative);
  91.         (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
  92.                                  what);
  93.         return;
  94.     case BackgroundPixmap:
  95.         if (pPrivWin->fastBackground)
  96.         {
  97.         mfbPaintWindow32(pWin, pRegion, what);
  98.         return;
  99.         }
  100.         break;
  101.     case BackgroundPixel:
  102.         if (pWin->background.pixel)
  103.         mfbSolidWhiteArea(pWin, REGION_NUM_RECTS(pRegion),
  104.                   REGION_RECTS(pRegion), GXset, NullPixmap);
  105.         else
  106.         mfbSolidBlackArea(pWin, REGION_NUM_RECTS(pRegion),
  107.                   REGION_RECTS(pRegion), GXclear, NullPixmap);
  108.         return;
  109.         }
  110.         break;
  111.     case PW_BORDER:
  112.     if (pWin->borderIsPixel)
  113.     {
  114.         if (pWin->border.pixel)
  115.         mfbSolidWhiteArea(pWin, REGION_NUM_RECTS(pRegion),
  116.                   REGION_RECTS(pRegion), GXset, NullPixmap);
  117.         else
  118.         mfbSolidBlackArea(pWin, REGION_NUM_RECTS(pRegion),
  119.                   REGION_RECTS(pRegion), GXclear, NullPixmap);
  120.         return;
  121.     }
  122.     else if (pPrivWin->fastBorder)
  123.     {
  124.         mfbPaintWindow32(pWin, pRegion, what);
  125.         return;
  126.     }
  127.     break;
  128.     }
  129.     miPaintWindow(pWin, pRegion, what);
  130. }
  131.  
  132. /* Tile Window with a 32 bit wide tile 
  133.    this could call mfbTileArea32, but that has to do a switch on the
  134. rasterop, which seems expensive.
  135. */
  136. static void
  137. mfbPaintWindow32(pWin, pRegion, what)
  138.     WindowPtr pWin;
  139.     RegionPtr pRegion;
  140.     int what;        
  141. {
  142.     int nbox;        /* number of boxes to fill */
  143.     register BoxPtr pbox;    /* pointer to list of boxes to fill */
  144.     int tileHeight;    /* height of the tile */
  145.     register int srcpix;    /* current row from tile */
  146.  
  147.     PixmapPtr pPixmap;
  148.     int nlwScreen;    /* width in longwords of the screen's pixmap */
  149.     int w;        /* width of current box */
  150.     register int nlw;    /* loop version of nlwMiddle */
  151.     register unsigned int *p;    /* pointer to bits we're writing */
  152.     register int h;    /* height of current box */
  153.     register int *psrc;    /* pointer to bits in tile */
  154.     int startmask;
  155.     int endmask;    /* masks for reggedy bits at either end of line */
  156.     int nlwMiddle;    /* number of longwords between sides of boxes */
  157.     int nlwExtra;    /* to get from right of box to left of next span */
  158.     
  159.     int y;        /* current scan line */
  160.  
  161.     unsigned int *pbits;    /* pointer to start of screen */
  162.     mfbPrivWin *pPrivWin;
  163.  
  164.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  165.  
  166.     if (what == PW_BACKGROUND)
  167.     {
  168.     tileHeight = pWin->background.pixmap->drawable.height;
  169.     pPixmap = pPrivWin->pRotatedBackground;
  170.     } 
  171.     else
  172.     {
  173.         tileHeight = pWin->border.pixmap->drawable.height;
  174.     pPixmap = pPrivWin->pRotatedBorder;
  175.     } 
  176.     if (!pPixmap)
  177.     {
  178.     miPaintWindow(pWin, pRegion, what);
  179.     return;
  180.     }
  181.     psrc = (int *)(pPixmap->devPrivate.ptr);
  182.  
  183.     pPixmap = (PixmapPtr)(pWin->drawable.pScreen->devPrivate);
  184.     pbits = (unsigned int *)pPixmap->devPrivate.ptr;
  185.     nlwScreen = (pPixmap->devKind) >> 2;
  186.     nbox = REGION_NUM_RECTS(pRegion);
  187.     pbox = REGION_RECTS(pRegion);
  188.  
  189.     while (nbox--)
  190.     {
  191.     w = pbox->x2 - pbox->x1;
  192.     h = pbox->y2 - pbox->y1;
  193.     y = pbox->y1;
  194.     p = pbits + (pbox->y1 * nlwScreen) + (pbox->x1 >> 5);
  195.  
  196.     if ( ((pbox->x1 & 0x1f) + w) < 32)
  197.     {
  198.         maskpartialbits(pbox->x1, w, startmask);
  199.         nlwExtra = nlwScreen;
  200.         while (h--)
  201.         {
  202.         srcpix = psrc[y%tileHeight];
  203.         y++;
  204.         *p = (*p & ~startmask) | (srcpix & startmask);
  205.         p += nlwExtra;
  206.         }
  207.     }
  208.     else
  209.     {
  210.         maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
  211.         nlwExtra = nlwScreen - nlwMiddle;
  212.  
  213.         if (startmask && endmask)
  214.         {
  215.         nlwExtra -= 1;
  216.         while (h--)
  217.         {
  218.             srcpix = psrc[y%tileHeight];
  219.             y++;
  220.             nlw = nlwMiddle;
  221.             *p = (*p & ~startmask) | (srcpix & startmask);
  222.             p++;
  223.             Duff (nlw, *p++ = srcpix );
  224.             *p = (*p & ~endmask) | (srcpix & endmask);
  225.             p += nlwExtra;
  226.         }
  227.         }
  228.         else if (startmask && !endmask)
  229.         {
  230.         nlwExtra -= 1;
  231.         while (h--)
  232.         {
  233.             srcpix = psrc[y%tileHeight];
  234.             y++;
  235.             nlw = nlwMiddle;
  236.             *p = (*p & ~startmask) | (srcpix & startmask);
  237.             p++;
  238.             Duff (nlw, *p++ = srcpix );
  239.             p += nlwExtra;
  240.         }
  241.         }
  242.         else if (!startmask && endmask)
  243.         {
  244.         while (h--)
  245.         {
  246.             srcpix = psrc[y%tileHeight];
  247.             y++;
  248.             nlw = nlwMiddle;
  249.             Duff (nlw, *p++ = srcpix);
  250.             *p = (*p & ~endmask) | (srcpix & endmask);
  251.             p += nlwExtra;
  252.         }
  253.         }
  254.         else /* no ragged bits at either end */
  255.         {
  256.         while (h--)
  257.         {
  258.             srcpix = psrc[y%tileHeight];
  259.             y++;
  260.             nlw = nlwMiddle;
  261.             Duff (nlw, *p++ = srcpix);
  262.             p += nlwExtra;
  263.         }
  264.         }
  265.     }
  266.         pbox++;
  267.     }
  268. }
  269. @
  270.